	$(function() {
		//应用标签加载
		loadYybqData();
		//应用标签默认勾选样式
		loadYybqDefaultCheckOutData(cCode);
		//发布时间默认选中样式
		fbsjActive("1");
		//产品列表加载
		loadCplbData(currentPage,cCode,"","1","",sName);
		//头部默认搜索名称修改
		defaultServerName();
	});

	//应用标签默认勾选样式
	function loadYybqDefaultCheckOutData(cCode){
		if(cCode!=""&&cCode!=null){
			$(".main_content_middle_condition_label_right_content[categoryCode="+cCode+"]").addClass("active");
			lastActive = cCode;
		}
	}

	//头部默认搜索名称修改
	function defaultServerName(){
		if(sName!=""&&sName!=null){
			$("#heade_input").val(sName);
		}
	}

	//列表标题
	function loadCplbTitleData(categoryCode){
		var titleText ="";
		if(categoryCode==""||categoryCode==null){
			titleText = "";
		}else{
			titleText = $(".main_content_middle_condition_label_right_content[categoryCode="+categoryCode+"]").text();
		}
		$("#list_title").text(titleText);
	}

	//发布时间默认选中样式
	function fbsjActive(code){
		$(".main_content_middle_list_table_right_title[code="+code+"]").addClass("title_active"); //默认选中样式
		titleActive = code;
	}


	//项目地址
	var baseUrl = "/apistore/";
	//当前显示第几页
	var currentPage=1;
	//一共多少页数据
	var totalPage;

	//应用标签
	function loadYybqData(){
		$.ajax({
			type: "POST",
			dataType: "JSON",
			async: false,
			url:baseUrl+'/categoryControler/selectByYybq',
			contentType:'application/json;charset=UTF-8',
			success: function (result) {
				if(result!=null){
					//应用标签加载
					var str = "";
					for(var i=0;i<result.length;i++){
						str+="<div class=\"main_content_middle_condition_label_right_content\" categoryCode=\""+result[i].categoryCode+"\">"+result[i].categoryName+"</div>";
					}
					$("#yybq").html(str);
				}else{
					$("#yybq").html("暂无数据");
				}
			},
			error: function (result) {
			}
		});
	}

	//产品列表
	function loadCplbData(pageNum,categoryCode,isGuarantee,ready03,ready04,sName){
		var data = {
			currentPage : pageNum,
			pageSize : 6,
			ready01 : categoryCode,	//应用标签
			ready02 : isGuarantee,	//有无担保
			ready03 : ready03,	//发布时间排序
			ready04 : ready04,	//调用次数排序
			ready05 : sName	//api名称
		};
		var url = baseUrl+'categoryControler/selectByServerHeaderPageList';
		$.ajax({
			url : url,
			data : data,
			type : 'POST',
			dataType: "JSON",
			success : function(data) {
				var dataLists = null;
				if (data != null) {
					dataLists = data.dataList;
					var str="";
					if (dataLists != null) {
						//当前第几页
						currentPage=data.currentPage;
						//一共多少页数据
						totalPage=data.totalPage;
						var id = "";
						for(var i=0;i<dataLists.length;i++){
							if(i==0){
								id = "img_lb0";
							}
							if(i==1){
								id = "img_lb1";
							}
							if(i==2){
								id = "img_lb2";
							}
							if(i==3){
								id = "img_lb3";
							}
							if(i==4){
								id = "img_lb4";
							}
							if(i==5){
								id = "img_lb5";
							}
							str+="<div class=\"main_content_middle_list_content_details\">";
							str+="<div class=\"main_content_middle_list_content_details_image\" serviceCode=\""+dataLists[i].serviceCode+"\" id=\""+id+"\"></div>";
							str+="<div class=\"main_content_middle_list_content_details_in\">";
							str+="<div class=\"main_content_middle_list_content_details_in_up\" serviceCode=\""+dataLists[i].serviceCode+"\">"+dataLists[i].serviceName+"</div>";
							str+="<div class=\"main_content_middle_list_content_details_in_bt\">"+dataLists[i].shortDesc+"</div>";
							str+="</div>";
							str+="<div class=\"main_content_middle_list_content_details_right\">";
							str+="<div class=\"main_content_middle_list_content_details_right_operation\">";
							str+="<div class=\"main_content_middle_list_content_details_right_operation_icons\"><i class=\"fa fa-calendar\"></i></div>";
							str+="<div class=\"main_content_middle_list_content_details_right_operation_text\">"+dataLists[i].releaseTime+"</div>";
							str+="</div>";
							str+="<div class=\"main_content_middle_list_content_details_right_operation\">";
							str+="<div class=\"main_content_middle_list_content_details_right_operation_icons\"><i class=\"fa fa-user-circle\"></i></div>";
							str+="<div class=\"main_content_middle_list_content_details_right_operation_text\">"+dataLists[i].recordCount+"</div>";
							str+="</div>";
							//str+="<div class=\"main_content_middle_list_content_details_right_operation\">";
							//str+="<div class=\"main_content_middle_list_content_details_right_operation_icons\"><i class=\"fa fa-sort\"></i></div>";
							//str+="<div class=\"main_content_middle_list_content_details_right_operation_text\">23</div>";
							str+="</div>";
							str+="</div>";
							str+="</div>";
						}
						//构建分页信息
						loadPage(data);
					}else{
						$("#page").text("");
						str+="<div class=\"context_item\">";
						str+="<div class=\"notdata\">暂无数据</div>";
						str+="</div>";
					}
					$("#apilb").html(str);
					if(dataLists != null){  //有数据的时候加载图片
						for(var i=0;i<dataLists.length;i++){
							//根据id给改变图片样式
							$("#img_lb"+i+"").css("background-image","url("+baseUrl+"localImg/"+dataLists[i].serviceImage+")");
						}
					}
				}
			},
			error : function(error) {
				alert("获取api列表失败！");
			}
		});
	}

	//构建分页信息
	function loadPage(data){
		$("#page").text("");
		var pageStr = "";
		var pageNum = 0;
		pageStr += "<div class=\"main_content_middle_list_page_div\">";
		pageStr += "<div class=\"main_content_middle_list_page_div_yeshu\" id=\"prePage\">&lt;上一页</div>";
		var startindex = currentPage;  //当前页数
		var endindex = totalPage;  //总页数
		var spacenumb = endindex - startindex;
		if (spacenumb > 5) {
			endindex = startindex + 4;
		} else {
			if (totalPage > 5) {
				startindex = totalPage - 4;
			} else {
				startindex = 1;
			}
		}
		for (var i = startindex; i <= endindex; i++) {
			if (currentPage === i) {  //active默认选中样式
				pageStr += "<div class=\"main_content_middle_list_page_div_number pageactive\" onclick=\"pageNum('" + i + "')\">" + i + "</div>"
			} else {
				pageStr += "<div class=\"main_content_middle_list_page_div_number\" onclick=\"pageNum('" + i + "')\">" + i + "</div>"
			}
		}
		pageStr += "<div class=\"main_content_middle_list_page_div_yeshu\" id=\"nextPage\">下一页&gt;</div>";
		pageStr += "</div>";
		//"合计"+data.totalPage+" 页"
		//"共 "+data.totalRecord+"  条记录
		$("#page").append(pageStr);
	}

	//上一页
	$(document).on("click","#prePage",function(){
		priviousPage();
	});

	//下一页
	$(document).on("click","#nextPage",function(){
		nextPage();
	});

	//下一页
	function nextPage(){
		if(currentPage==totalPage){
			alert("已经是最后一页数据!");
			return false;
		}else{
			var categoryCode = "";
			if($(".main_content_middle_condition_label_right_content").is(".active")){ 		//加载列表之前判断应用标签有没有被选中
				categoryCode = $(".main_content_middle_condition_label_right_content.active").attr("categoryCode") 	//查找有没有active的样式，有就拿到它的值
			}else{
				categoryCode = "";	//没有就是空值
			}
			var isGuarantee = "";
			if($(".main_content_middle_condition_guarantee_right_content").is(".active")){ 		//加载列表之前判断有无担保有没有被选中
				isGuarantee = $(".main_content_middle_condition_guarantee_right_content.active").attr("isGuarantee") 	//查找有没有active的样式，有就拿到它的值
			}else{
				isGuarantee = "";	//没有就是空值
			}
			var code = $(".main_content_middle_list_table_right_title.title_active").attr("code");
			var heade_input = $("#heade_input").val();
			if(code =="1"){
				loadCplbData(currentPage+1,categoryCode,isGuarantee,code,"",heade_input);
			}else{
				loadCplbData(currentPage+1,categoryCode,isGuarantee,"",code,heade_input);
			}
			return true;
		}
	};

	//当前页数加载
	function pageNum(pageNum){
		var categoryCode = "";
		if($(".main_content_middle_condition_label_right_content").is(".active")){ 		//加载列表之前判断应用标签有没有被选中
			categoryCode = $(".main_content_middle_condition_label_right_content.active").attr("categoryCode") 	//查找有没有active的样式，有就拿到它的值
		}else{
			categoryCode = "";	//没有就是空值
		}
		var isGuarantee = "";
		if($(".main_content_middle_condition_guarantee_right_content").is(".active")){ 		//加载列表之前判断有无担保有没有被选中
			isGuarantee = $(".main_content_middle_condition_guarantee_right_content.active").attr("isGuarantee") 	//查找有没有active的样式，有就拿到它的值
		}else{
			isGuarantee = "";	//没有就是空值
		}
		var code = $(".main_content_middle_list_table_right_title.title_active").attr("code");
		var heade_input = $("#heade_input").val();
		if(code =="1"){
			loadCplbData(pageNum,categoryCode,isGuarantee,code,"",heade_input);
		}else{
			loadCplbData(pageNum,categoryCode,isGuarantee,"",code,heade_input);
		}
	}

	//上一页
	function priviousPage(){
		if(currentPage==1){
			alert("已经是第一页数据!");
			return false;
		}else{
			var categoryCode = "";
			if($(".main_content_middle_condition_label_right_content").is(".active")){ 		//加载列表之前判断应用标签有没有被选中
				categoryCode = $(".main_content_middle_condition_label_right_content.active").attr("categoryCode") 	//查找有没有active的样式，有就拿到它的值
			}else{
				categoryCode = "";	//没有就是空值
			}
			var isGuarantee = "";
			if($(".main_content_middle_condition_guarantee_right_content").is(".active")){ 		//加载列表之前判断有无担保有没有被选中
				isGuarantee = $(".main_content_middle_condition_guarantee_right_content.active").attr("isGuarantee") 	//查找有没有active的样式，有就拿到它的值
			}else{
				isGuarantee = "";	//没有就是空值
			}
			var code = $(".main_content_middle_list_table_right_title.title_active").attr("code");
			var heade_input = $("#heade_input").val();
			if(code =="1"){
				loadCplbData(currentPage-1,categoryCode,isGuarantee,code,"",heade_input);
			}else{
				loadCplbData(currentPage-1,categoryCode,isGuarantee,"",code,heade_input);
			}
			return true;
		}
	}

	//判断为数据库null
	function isNull(reason){
		if(reason!=null&&reason!=""&&reason!="null"){
			return reason;
		}else{
			return "无";
		}
	}


	var lastActive = "";	//记录应用标签上一次点击的样式，是否被选中
	//应用标签点击事件
	$(document).on("click",".main_content_middle_condition_label_right_content",function(e){
		var categoryCode = $(this).attr("categoryCode");
		if(lastActive !=""&&lastActive !=null){		//上一次又没有选中的  有就是取消上次选中样式，勾选这次选中样式
			if(lastActive==categoryCode){	//如果上次选中样式和这次一样，那么取消这次选中样式
				$(this).removeClass("active");  //去掉选中样式
				categoryCode = "";
			}else{
				$(".main_content_middle_condition_label_right_content[categoryCode="+lastActive+"]").removeClass("active");		//取消上次选中样式
				$(this).addClass("active");  //添加选中样式
			}
		}else{	//没有  直接选中这个勾选样式
			$(this).addClass("active");  //添加选中样式
		}
		lastActive = categoryCode;
		var isGuarantee = "";
		if($(".main_content_middle_condition_guarantee_right_content").is(".active")){ 		//加载列表之前判断有无担保有没有被选中
			isGuarantee = $(".main_content_middle_condition_guarantee_right_content.active").attr("isGuarantee") 	//查找有没有active的样式，有就拿到它的值
		}else{
			isGuarantee = "";	//没有就是空值
		}
		//列表标题
		loadCplbTitleData(categoryCode);
		var code = $(".main_content_middle_list_table_right_title.title_active").attr("code");
		var heade_input = $("#heade_input").val();
		if(code =="1"){
			loadCplbData(currentPage,categoryCode,isGuarantee,code,"",heade_input);
		}else{
			loadCplbData(currentPage,categoryCode,isGuarantee,"",code,heade_input);
		}
	});



	var isActive = "";	//记录有无担保上一次点击的样式，是否被选中
	//有无担保点击事件
	$(document).on("click",".main_content_middle_condition_guarantee_right_content",function(e){
		//判断已担保被选中，就取消未担保选中状态；未担保被选中，就取消已担保选中状态；
		var isGuarantee = $(this).attr("isGuarantee");
		if(isGuarantee=="有"){
			if(isActive==isGuarantee){  //如果两次选中一样，取消当前样式，不加删选条件
				$(this).removeClass("active");  //去掉选中样式
				isGuarantee = "";
			}else{
				$(this).addClass("active");  //添加选中样式
				$(".main_content_middle_condition_guarantee_right_content[isGuarantee='无']").removeClass("active");
			}
		}else{
			if(isActive==isGuarantee){	//如果两次选中一样，取消当前样式，不加删选条件
				$(this).removeClass("active");  //去掉选中样式
				isGuarantee = "";
			}else{
				$(this).addClass("active");  //添加选中样式
				$(".main_content_middle_condition_guarantee_right_content[isGuarantee='有']").removeClass("active");
			}
		}
		isActive = isGuarantee;
		//加载列表之前判断应用标签有没有被选中
		var categoryCode = "";
		if($(".main_content_middle_condition_label_right_content").is(".active")){ 		//加载列表之前判断有无担保有没有被选中
			categoryCode = $(".main_content_middle_condition_label_right_content.active").attr("categoryCode") 	//查找有没有active的样式，有就拿到它的值
		}else{
			categoryCode = "";	//没有就是空值
		}
		var code = $(".main_content_middle_list_table_right_title.title_active").attr("code");
		var heade_input = $("#heade_input").val();
		if(code =="1"){
			loadCplbData(currentPage,categoryCode,isGuarantee,code,"",heade_input);
		}else{
			loadCplbData(currentPage,categoryCode,isGuarantee,"",code,heade_input);
		}
	});

	var titleActive = "";	//记录上一次排序的序号
	//排序点击事件
	$(document).on("click",".main_content_middle_list_table_right_title",function(e){
		var code = $(this).attr("code");
		if(titleActive==""){
			$(this).addClass("title_active");  //添加选中样式
		}else{
			$(this).addClass("title_active");  //添加选中样式
			$(".main_content_middle_list_table_right_title[code='"+titleActive+"']").removeClass("title_active");
		}
		//加载列表之前判断应用标签有没有被选中
		var categoryCode = "";
		if($(".main_content_middle_condition_label_right_content").is(".active")){ 		//加载列表之前判断有无担保有没有被选中
			categoryCode = $(".main_content_middle_condition_label_right_content.active").attr("categoryCode") 	//查找有没有active的样式，有就拿到它的值
		}else{
			categoryCode = "";	//没有就是空值
		}
		//加载列表之前判断有无担保有没有被选中
		var isGuarantee = "";
		if($(".main_content_middle_condition_guarantee_right_content").is(".active")){ 		//加载列表之前判断有无担保有没有被选中
			isGuarantee = $(".main_content_middle_condition_guarantee_right_content.active").attr("isGuarantee") 	//查找有没有active的样式，有就拿到它的值
		}else{
			isGuarantee = "";	//没有就是空值
		}
		var heade_input = $("#heade_input").val();
		if(code =="1"){
			loadCplbData(currentPage,categoryCode,isGuarantee,code,"",heade_input);
		}else{
			loadCplbData(currentPage,categoryCode,isGuarantee,"",code,heade_input);
		}
		titleActive = code;
	});

	//API详情跳转事件
	$(document).on("click",".main_content_middle_list_content_details_image",function(e){
		var serverCode = $(this).attr("serviceCode");
		window.location.href=baseUrl+"apidetail?serviceCode="+serverCode;
	});

	//API详情跳转事件
	$(document).on("click",".main_content_middle_list_content_details_in_up",function(e){
		var serverCode = $(this).attr("serviceCode");
		window.location.href=baseUrl+"apidetail?serviceCode="+serverCode;
	});